﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using HeapModel.ProgInfo;
using HeapModel.ConcreteMemory;

namespace HeapModel.RegionPartition
{
	/// <summary>
	/// This struct is used to represent edges between regions for use in the metric processor
	/// </summary>
	public struct RegionEdgeInfo
	{
		public enum Orientation
		{
			UnSet,
			Tree,
			Cross,
			Back
		}

		/// <summary>
		/// Source of the edge, null for heap root sources
		/// </summary>
		public readonly RegionNode Source;

		/// <summary>
		/// Target of the edge
		/// </summary>
		public readonly RegionNode Target;

		/// <summary>
		/// The storate location of the pointers
		/// </summary>
		public readonly AccessPath Offset;

		/// <summary>
		/// If the edge is injective
		/// </summary>
		public readonly bool IsInjective;

		/// <summary>
		/// If the edge is nonnull
		/// </summary>
		public readonly bool IsNonNull;

		public readonly Orientation EdgeOrientation;

		public RegionEdgeInfo(RegionNode source, RegionNode target, AccessPath offset, bool isinjective, bool isnonnull, Orientation eo)
		{
			this.Source = source;
			this.Target = target;
			this.Offset = offset;
			this.IsInjective = isinjective | (target == null);
			this.IsNonNull = isnonnull;
			this.EdgeOrientation = eo;
		}
	}
}
